/*
 * @Author: your name
 * @Date: 2021-09-22 21:23:39
 * @LastEditTime: 2021-09-22 22:52:17
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /professional-node/gulp-work/gulpfile.js
 */
const { series, src, dest } = require('gulp');
const uglify = require('gulp-uglify');
const babel = require('gulp-babel');
const gulpCleanCss = require('gulp-clean-css')
const uglifycss = require('gulp-uglifycss');
const sass = require("gulp-sass")(require('sass'))
// const imagemin = require('gulp-image');
// import imagemin from 'gulp-imagemin'
 // src 找，我要执行谁
// dest 我要把执行完的结果，输出到哪儿
// pipe 执行一个一个任务
/**
 * 
 * js:
 * 1. 处理es6- es5  gulp-babel @babel/core @babel/preset-env
 * 2. 压缩  gulp-uglify
 * 
 * scss:
 * 1. scss - css : require("gulp-sass")(require('sass'))
 * 2. 压缩 
 * 
 * 
 * 
 * 
 */
function clean(cb) {
  return src('./src/js/*.js')
  .pipe(uglify())
  .pipe(babel({
    presets: ['@babel/preset-env']
  }))
  .pipe(dest('output'));
}

function scss() {
  return src('./src/css/*.scss')
  .pipe(sass())
  .pipe(uglifycss())
  .pipe(gulpCleanCss())
  .pipe(dest('output/css'))
}

// function image() {
//   return src('./src/images/*')
//   .pipe(imagemin())
//   .pipe(dest('dest/images'))
// }


function build(cb) {
  // body omitted
  cb();
}


// html / css / sass / img / js




exports.scss = scss;
exports.clean = clean;
// exports.image = image;

// exports.default = series(clean, build); 
